//
//  CgCRootViewContronller.m
//  rxtd_bdd
//
//  Created by 陈利群 on 15/4/12.
//  Copyright (c) 2015年 陈利群. All rights reserved.
//

#import "CgCRootViewContronller.h"
#import "IndexViewController.h"
#import "Tab2ViewController.h"
#import "Tab3ViewController.h"
#import "PersonCenterViewController.h"
//#import "LoginViewController.h"
@implementation CgCRootViewContronller


- (id)init
{
  self =  [super init];
    if(self)
    {
        [self registerNotification];
        [self loadRootViewController];
    }
    
    return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    

        
      
            
    }
    return self;
}

- (void)registerNotification
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(presentLoginViewController:) name:CMD_PresentControlelr_LoginViewController object:nil];
    
}
- (void) loadRootViewController
{
    IndexViewController* cgcWaybillInfosVC = [[IndexViewController alloc] init ];
//    cgcWaybillInfosVC.vcType = 0;
    self.tab1 = [[UINavigationController alloc] initWithRootViewController:cgcWaybillInfosVC];
    
    UITabBarItem* tabBarItem_production = [[UITabBarItem alloc] init];
    tabBarItem_production.title = @"资讯";
    tabBarItem_production.selectedImage = [[UIImage imageNamed:@"t1_1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
    tabBarItem_production.image = [[UIImage imageNamed:@"t1_0"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [tabBarItem_production setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBCOLOR(164,164,164)} forState:UIControlStateNormal];
    [tabBarItem_production setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBCOLOR(250, 83, 92)} forState:UIControlStateSelected];
    [tabBarItem_production setTag:0];
    [self.tab1 setTabBarItem:tabBarItem_production];
    
    
    Tab2ViewController *cgcWaybillPathVc = [[Tab2ViewController alloc] init];
    cgcWaybillPathVc.title = @"图书";
    self.tab2 = [[UINavigationController alloc] initWithRootViewController:cgcWaybillPathVc];
    
    UITabBarItem* tabBarItem_myLoans = [[UITabBarItem alloc] init];
    tabBarItem_myLoans.title = @"图书";
    tabBarItem_myLoans.selectedImage = [[UIImage imageNamed:@"t2_1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem_myLoans.image = [[UIImage imageNamed:@"t2_0"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [tabBarItem_myLoans setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBCOLOR(164,164,164)} forState:UIControlStateNormal];
    [tabBarItem_myLoans setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBCOLOR(250, 83, 92)} forState:UIControlStateSelected];
    [tabBarItem_myLoans setTag:1];
    [self.tab2 setTabBarItem:tabBarItem_myLoans];
    
    

    Tab3ViewController *cgcFindGoodsVC = [[Tab3ViewController alloc] init];
    self.tab3 = [[UINavigationController alloc] initWithRootViewController:cgcFindGoodsVC];
    UITabBarItem* tabBarItem_hp = [[UITabBarItem alloc] init];
    
    tabBarItem_hp.title = @"黑板";
    tabBarItem_hp.selectedImage = [[UIImage imageNamed:@"t3_1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
    tabBarItem_hp.image = [[UIImage imageNamed:@"t3_0"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    [tabBarItem_hp setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBCOLOR(164,164,164)} forState:UIControlStateNormal];
    [tabBarItem_hp setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBCOLOR(250, 83, 92)} forState:UIControlStateSelected];
    [tabBarItem_hp setTag:2];
    [self.tab3 setTabBarItem:tabBarItem_hp];


    PersonCenterViewController* cgcPersonCenterVC = [[PersonCenterViewController alloc] init];
    self.tab4 = [[UINavigationController alloc] initWithRootViewController:cgcPersonCenterVC];
    UITabBarItem* tabBarItem_about = [[UITabBarItem alloc] init];
    tabBarItem_about.title = @"我的";
    tabBarItem_about.selectedImage = [[UIImage imageNamed:@"t4_1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
    tabBarItem_about.image = [[UIImage imageNamed:@"t4_0"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [tabBarItem_about setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBCOLOR(164,164,164)} forState:UIControlStateNormal];
    [tabBarItem_about setTitleTextAttributes:@{NSForegroundColorAttributeName:RGBCOLOR(250, 83, 92)} forState:UIControlStateSelected];
    [tabBarItem_about setTag:3];
    [self.tab4 setTabBarItem:tabBarItem_about];

    
    self.viewControllers = [NSArray arrayWithObjects:self.tab1, self.tab2, self.tab3, self.tab4, nil];
    
    self.selectedIndex = 0;
    [UITabBar appearance].translucent = NO;
}


#pragma mark - // Optional UITabBarControllerDelegate method.

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
    BOOL should = YES;

    return should;
}

#pragma mark - // 弹出登录界面
- (void)presentLoginViewController:(NSNotification *)notification
{

    
}


#pragma mark - //返回首页
- (void)gotoHomePageSelector:(id)sender
{

}
#pragma mark - //登出
-(void) loginout:(id)sender
{


}
#pragma mark - // 登出成功

-(void) loginoutDidFinishSelector:(NSNotification*) notification
{
}
#pragma mark - // 登录成功之后的方法
- (void)loginDidFinishSelector:(NSNotification *)notification {

}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
